PWD = $(shell pwd)
BIN_DIR = $(PWD)/bin

ACT_RUNNER_VERSION = 3.0.1

ACT_RUNNER_URL = https://gitverse.ru/sc/api/packages/gitverse/generic/act_runner/${ACT_RUNNER_VERSION}/act_runner
ACT_RUNNER = $(BIN_DIR)/act_runner

GOLANGCI_LINT_VERSION = v1.57.1

GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
ifeq ($(OS), Windown_NT)
	GOLANGCI_LINT := $(GOLANGCI_LINT).exe
endif


$(shell [ -f $(BIN_DIR) ] || mkdir -p $(BIN_DIR))

.PHONY:.install_act_runner
.install_act_runner:
	$(shell [ -f $(ACT_RUNNER) ] || curl -sSfL ${ACT_RUNNER_URL} --output $(ACT_RUNNER))


.PHONY:.install-linter
.install-linter:
	$(shell [ -f $(GOLANGCI_LINT) ] || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) $(GOLANGCI_LINT_VERSION))

.PHONY:lint
lint:.install-linter
	$(GOLANGCI_LINT) run ./... --config=./.golangci.yml

.PHONY:lint-fast
lint-fast:.install-linter
	$(GOLANGCI_LINT) run ./... --fast --config=./.golangci.yml

.PHONY:test
test:
	go test -v -race --timeout 30s ./...


.DEFAULT_GOAL := build